Hello, |
Re: Deleting objects with links However, I'm still having problems deleting incoming links. When I have an object with incoming links and I delete that object I get this error: "cannot delete Object: object has incoming links" How can I fix that and force the deletion? Thanks for your help. |
Re: Deleting objects with links SystemAdmin - Sat Mar 19 19:52:35 EDT 2011
The rules for deleting incoming links are:
Object o=current
Module m=current
int count=0
void deleteIncomingLinks(Object o) {
Module modSrc=null
Link l
// Load all source modules
ModName_ srcModRef
string srcModName=""
for srcModRef in o<-"*" do {
srcModName=fullName(srcModRef)
modSrc=edit(srcModName, false)
}
// Delete all incoming links
if(!null modSrc) { //if modSrc is null, then current user cannot open this mod for edit
for l in o<-"*" do {
Object objSrc=source l
count++
delete l
}
flushDeletions
}
else print "Failed to get access to source module(s) \n"
} //End of deleteIncomingLinks
//***************** MAIN ********************
if(null o) {
warningBox "No Object has been selected"
halt
}
o = current
if(!null o) {
if(!confirm "Delete all incoming links to this object?") halt
deleteIncomingLinks(o)
infoBox "Deleted " count " links"
save m
}
else {
warningBox "No object selected"
}
Paul Miller
|
Re: Deleting objects with links SystemAdmin - Sun Mar 20 02:02:52 EDT 2011
The rules for deleting incoming links are:
Object o=current
Module m=current
int count=0
void deleteIncomingLinks(Object o) {
Module modSrc=null
Link l
// Load all source modules
ModName_ srcModRef
string srcModName=""
for srcModRef in o<-"*" do {
srcModName=fullName(srcModRef)
modSrc=edit(srcModName, false)
}
// Delete all incoming links
if(!null modSrc) { //if modSrc is null, then current user cannot open this mod for edit
for l in o<-"*" do {
Object objSrc=source l
count++
delete l
}
flushDeletions
}
else print "Failed to get access to source module(s) \n"
} //End of deleteIncomingLinks
//***************** MAIN ********************
if(null o) {
warningBox "No Object has been selected"
halt
}
o = current
if(!null o) {
if(!confirm "Delete all incoming links to this object?") halt
deleteIncomingLinks(o)
infoBox "Deleted " count " links"
save m
}
else {
warningBox "No object selected"
}
Paul Miller
Had a closer look at the utility script I posted above, it works but there are some flaws, so have posted an improved version - the main changes are an improved method to trap source modules that cannot be opened for edit, and added some code that will save the source modules after the links have been deleted - that's an import aspect to deleting incoming links, you have to save the source modules otherwise the links will not be actually deleted.
Object o=current
Module m=current
int count=0
void deleteIncomingLinks(Object o) {
Module modSrc=null
Module sourceMod=null
Link l
bool allModsOpen = true
ModuleVersion sourceModVersion = null
// Open all modules that are the source of incoming links in edit mode
ModName_ srcModRef
string srcModName=""
for srcModRef in o<-"*" do {
srcModName=fullName(srcModRef)
modSrc=edit(srcModName, false)
if (null modSrc) { //provide a warning if a source cannot be opened in edit mode
infoBox "Cannot open for Edit module: " srcModName
allModsOpen = false
}
}
// Delete all incoming links
if(allModsOpen) {
for l in o<-"*" do {
Object objSrc=source l
sourceModVersion = sourceVersion l
srcModRef = module(sourceModVersion)
modSrc=edit(fullName(srcModRef), false)
count++
delete l
save modSrc
}
flushDeletions
}
else print "Failed to get access to source module(s) \n"
} //End of deleteIncomingLinks
//***************** MAIN ********************
if(null o) {
warningBox "No Object has been selected"
halt
}
o = current
if(!null o) {
if(!confirm "Delete all incoming links to this object?") halt
deleteIncomingLinks(o)
infoBox "Deleted " count " links"
save m
}
else {
warningBox "No object selected"
}
Paul Miller
|
Re: Deleting objects with links SystemAdmin - Sun Mar 20 02:51:07 EDT 2011
Had a closer look at the utility script I posted above, it works but there are some flaws, so have posted an improved version - the main changes are an improved method to trap source modules that cannot be opened for edit, and added some code that will save the source modules after the links have been deleted - that's an import aspect to deleting incoming links, you have to save the source modules otherwise the links will not be actually deleted.
Object o=current
Module m=current
int count=0
void deleteIncomingLinks(Object o) {
Module modSrc=null
Module sourceMod=null
Link l
bool allModsOpen = true
ModuleVersion sourceModVersion = null
// Open all modules that are the source of incoming links in edit mode
ModName_ srcModRef
string srcModName=""
for srcModRef in o<-"*" do {
srcModName=fullName(srcModRef)
modSrc=edit(srcModName, false)
if (null modSrc) { //provide a warning if a source cannot be opened in edit mode
infoBox "Cannot open for Edit module: " srcModName
allModsOpen = false
}
}
// Delete all incoming links
if(allModsOpen) {
for l in o<-"*" do {
Object objSrc=source l
sourceModVersion = sourceVersion l
srcModRef = module(sourceModVersion)
modSrc=edit(fullName(srcModRef), false)
count++
delete l
save modSrc
}
flushDeletions
}
else print "Failed to get access to source module(s) \n"
} //End of deleteIncomingLinks
//***************** MAIN ********************
if(null o) {
warningBox "No Object has been selected"
halt
}
o = current
if(!null o) {
if(!confirm "Delete all incoming links to this object?") halt
deleteIncomingLinks(o)
infoBox "Deleted " count " links"
save m
}
else {
warningBox "No object selected"
}
Paul Miller
|
Re: Deleting objects with links SystemAdmin - Sun Mar 20 02:51:07 EDT 2011
Had a closer look at the utility script I posted above, it works but there are some flaws, so have posted an improved version - the main changes are an improved method to trap source modules that cannot be opened for edit, and added some code that will save the source modules after the links have been deleted - that's an import aspect to deleting incoming links, you have to save the source modules otherwise the links will not be actually deleted.
Object o=current
Module m=current
int count=0
void deleteIncomingLinks(Object o) {
Module modSrc=null
Module sourceMod=null
Link l
bool allModsOpen = true
ModuleVersion sourceModVersion = null
// Open all modules that are the source of incoming links in edit mode
ModName_ srcModRef
string srcModName=""
for srcModRef in o<-"*" do {
srcModName=fullName(srcModRef)
modSrc=edit(srcModName, false)
if (null modSrc) { //provide a warning if a source cannot be opened in edit mode
infoBox "Cannot open for Edit module: " srcModName
allModsOpen = false
}
}
// Delete all incoming links
if(allModsOpen) {
for l in o<-"*" do {
Object objSrc=source l
sourceModVersion = sourceVersion l
srcModRef = module(sourceModVersion)
modSrc=edit(fullName(srcModRef), false)
count++
delete l
save modSrc
}
flushDeletions
}
else print "Failed to get access to source module(s) \n"
} //End of deleteIncomingLinks
//***************** MAIN ********************
if(null o) {
warningBox "No Object has been selected"
halt
}
o = current
if(!null o) {
if(!confirm "Delete all incoming links to this object?") halt
deleteIncomingLinks(o)
infoBox "Deleted " count " links"
save m
}
else {
warningBox "No object selected"
}
Paul Miller
Hi paul, I tried to adapt your code to delete links on all objects in a module with a certain status with no luck. i added a basic loop and anything else is above my head frankly. Would you be able to give me some pointers on how to loop through all objects and just delete the links on certain objects where an attribute meets my criteria? thanks
for o in m do {
string sstatus = probeAttr_(obj,"Status")
if (sstatus == "Deleted") {
}
}
|
Re: Deleting objects with links bmohamed - Sun Apr 24 18:08:35 EDT 2016 Hi paul, I tried to adapt your code to delete links on all objects in a module with a certain status with no luck. i added a basic loop and anything else is above my head frankly. Would you be able to give me some pointers on how to loop through all objects and just delete the links on certain objects where an attribute meets my criteria? thanks
for o in m do {
string sstatus = probeAttr_(obj,"Status")
if (sstatus == "Deleted") {
}
}
Instead of adapting a script, easy solution may be to create a filter then delete links on remaining objects. |
Re: Deleting objects with links DOORSHAM - Mon Apr 25 21:58:02 EDT 2016 Instead of adapting a script, easy solution may be to create a filter then delete links on remaining objects. I created the filter. The step I want to automate is not having to click each object one by one to run the deletelinks dxl from the editdxl window if i could. thanks! PS...unless i'm misunderstanding your solution, doorsham... |